<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class="box" id="box1">盒子1</div>
    <div class="box" id="box2">盒子2</div>
    <div id="nav">
        <ul>
            <li>你会不会忽然的出现</li>
            <li>在街角的咖啡店</li>
            <li>我会带着笑脸</li>
            <li>挥手寒暄</li>
        </ul>
    </div>

    <script>
        // 1.getElementsByClassName 根据类名获得某些元素集合
        let boxs =document.getElementsByClassName('box');
        console.log(boxs);

        // 2.返回符合条件的第一个元素
        console.log(document.querySelector('.box'));
        console.log(document.querySelector('#box1'));
        console.log(document.querySelector('#box2'));
        console.log(document.querySelector('#nav'));
        console.log(document.querySelector('li'));

        // 3.返回数组
        console.log(document.querySelectorAll('li'));
        
    </script>
</body>
</html>